<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file='../share_header.jsp' %>
<div id="content-header">
    <h1>权限管理</h1>
</div>
<%--<div id="breadcrumb">--%>
<%--&lt;%&ndash;<a href="index.html" class="tip-bottom" data-original-title="Go to Home"><i class="icon-home"></i> Home</a>&ndash;%&gt;--%>
<%--<a href="javascript:void(0)"--%>
<%--url="${pageContext.request.contextPath}/crm/getMyselfClientInfo.do"  class="m-pageChange tip-bottom">权限管理</a>--%>
<%--<a href="#" class="current">权限管理</a>--%>
<%--</div>--%>
<div class="container-fluid marginTop20">
    <div class="row-fluid topCircleBorder paddingTop10 paddingBottom10 marginBottom5">
        <div class="span6">
            <div class="formLayOut">
                <div class="field">
                    <label for="permissionCode" class="control-label">权限Code</label>
                    <input class="text" type="text" id="permissionCode">
                </div>
            </div>

            <div class="formLayOut" style="margin-left: 28px">
                <button id="searchPermissionName" class="btn btn-primary">查询</button>
            </div>
        </div>
        <div class="offset3 span2" style="margin-left: 245px;">
            <button id="addPermissionBtn" class="btn btn-primary addButtonSize rightLayOut"><i class=" icon-plus"></i>添加
            </button>
        </div>
    </div>

    <div class="row-fluid">
        <table id="permissionManageTable">
        </table>
    </div>
    <!-- Modal -->
    <div id="permissionManageModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3 id="myModalLabel">用户菜单授权</h3>
        </div>
        <div class="modal-body">
            <div>
                <div class="formLayOut modifyPadding">
                    <span>权限ID:&nbsp;</span>
                    <span class="fireText" id="permissionIdDisabled"/>
                    <span>&nbsp;&nbsp;</span>
                </div>
                <div class="formLayOut modifyPadding fontColor">
                    <span>权限Code:&nbsp;</span>
                    <span class="fireText" id="permissionCodeDisabled"/>
                    <span>&nbsp;&nbsp;</span>
                </div>
                <div class="formLayOut modifyPadding fontColor">
                    <span>权限名称:&nbsp;</span>
                    <span class="fireText" id="permissionNameDisabled"/>
                    <span>&nbsp;&nbsp;</span>
                </div>
            </div>

            <table id="permissionMenuTable">
            </table>
        </div>
        <div class="modal-footer">
            <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
            <button id="permissionSaveBtn" type="button" class="btn btn-primary">提交</button>
        </div>
    </div>

    <!-- Modal -->
    <div id="permissionModifyModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <form id="modifyPermissionForm" action="javascript:permissionModifySave()">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h3 id="permissionModifyModalLabel">权限修改</h3>
            </div>
            <div class="modal-body">

                <div class="form-group">
                    <div class="field">
                        <label for="priviledgeId" class="control-label">权限ID</label>
                        <input type="text" name="priviledgeId" id="priviledgeId" readonly/>
                    </div>
                </div>
                <div class="form-group formLayOut">
                    <div class="field">
                        <label for="priviledgeCode" class="control-label">权限Code</label>
                        <input type="text" name="priviledgeCode" id="priviledgeCode"/>
                    </div>
                </div>
                <div class="form-group formLayOut">
                    <div class="field">
                        <label for="priviledgeName" class="control-label">权限名称</label>
                        <input type="text" name="priviledgeName" id="priviledgeName"/>
                    </div>
                </div>

            </div>
            <div class="modal-footer">
                <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
                <button id="permissionModifySaveBtn" type="submit" class="btn btn-primary">提交</button>
            </div>
        </form>
    </div>

    <!-- Modal -->
    <div id="permissionAddModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <form id="addPermissionForm" action="javascript:permissionAddSave()">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h3>添加权限</h3>
            </div>
            <div class="modal-body">
                <div class="control-group">
                    <div class="field">
                        <label for="priviledgeCode" class="control-label">权限Code</label>
                        <input type="text" name="priviledgeCode" id="priviledgeCode"/>
                    </div>
                </div>
                <div class="control-group">
                    <div class="field">
                        <label for="priviledgeName" class="control-label">权限名称</label>
                        <input type="text" name="priviledgeName" id="priviledgeName"/>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
                <button type="submit" class="btn btn-primary">提交</button>
            </div>
        </form>
    </div>
</div>
<script src="${pageContext.request.contextPath}/resources/js/permission/permissionManage.js"></script>
<script>
    $(function () {
        //页面数据初始化
        gotoPage(1);

        $("#addPermissionForm").validate({
            errorElement: 'div',
            errorClass: 'help-inline',
            focusInvalid: false,
            rules: {
                priviledgeCode: {
                    required: true
                },
                priviledgeName: {
                    required: true
                }
            },
            messages: {
                priviledgeCode: {
                    required: "权限Code不能为空"
                },
                priviledgeName: {
                    required: "权限名称不能为空"
                }
            },
            highlight: function (element) {
                $(element).closest('.control-group').addClass('error');
            },
            success: function (label) {
                label.closest('.control-group').removeClass('error');
                label.remove();
            },
            errorPlacement: function (error, element) {
                element.parent('.field').append(error);
            }

        });


    });
</script>
